#include <iostream>
#include "../logs/log.h"

void testLog(const std::string& name)
{
    LOGDEBUG("%s", "测试开始....");
    Log::Logger::ptr logger = Log::LoggerManager::getInstance().getLogger(name);
    std::string str = "日志系统项目代码测试";
    logger->DEBUG("%s", str.c_str());
    logger->INFO("%s", str.c_str());
    logger->WARNNING("%s", str.c_str());
    logger->ERROR("%s", str.c_str());
    logger->FATAL("%s", str.c_str());  
    LOGINFO("%s", "测试完毕!");    

}

int main()
{
    std::unique_ptr<Log::LoggerBuilder> builder(new Log::GlobalLoggerBuilder()); 
    builder->buildLoggerType(Log::LoggerType::LOGGER_SYNC);    //日志器类型的选择: 同步日志器/异步日志器
    const std::string loggerName = "syncLogger-1";
    //builder->buildEnableDynamicAsync(Log::BufferType::DYNAMICGROW);   //日志器的缓冲区类型: 动态增长类型的缓冲区
    builder->buildLoggerName(loggerName);
    builder->buildLimitLevel(Log::LogLevel::value::INFO);
    builder->buildFormatter("[%d{%Y-%m-%d %H:%M:%S}][%t][%f: %l]:[%p]%T[%c]%T%m%n");
    builder->buildSinks<Log::StdoutLogSink>();
    builder->buildSinks<Log::FileLogSink>("./logfile/sync.log");
    builder->buildSinks<Log::RollByFileSizeLogSink>("./logfile/rollsize-", 1024 * 1024);
    Log::Logger::ptr logger = builder->build();
    testLog(loggerName);

    return 0;
}


